/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class BBIChart extends JPanel
/*     */   implements MouseMotionListener, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private int parm2;
/*     */   private int[] bbi;
/*     */   private float[] bbiMa_parm1;
/*     */   private float[] bbiMa_parm2;
/*     */   private BBIInterface[] indicators;
/*  23 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  25 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private double p111Y;
/*     */   private double p222Y;
/*     */   private JTextField parm1TF;
/*     */   private JTextField parm2TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  33 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */ 
/*  35 */   public String trend = "";
/*     */   public BBIChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 460 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 461 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 462 */   private Line2D.Double refL1 = new Line2D.Double();
/* 463 */   private Line2D.Double refL2 = new Line2D.Double();
/* 464 */   private Line2D.Double gridY = new Line2D.Double();
/* 465 */   private Line2D.Double gridX = new Line2D.Double();
/* 466 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 467 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 472 */   private Line2D.Double l3 = new Line2D.Double();
/* 473 */   private Line2D.Double l1 = new Line2D.Double();
/* 474 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 476 */   private Line2D.Double uA = new Line2D.Double();
/* 477 */   private Line2D.Double lA = new Line2D.Double();
/* 478 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public BBIChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2, BBIInterface[] paramArrayOfBBIInterface)
/*     */   {
/*  40 */     this.sq = paramSymQuotes;
/*  41 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  43 */     this.bbi = new int[paramSymQuotes.count];
/*     */ 
/*  45 */     this.indicators = paramArrayOfBBIInterface;
/*  46 */     this.parm1 = paramInt1;
/*  47 */     this.parm2 = paramInt2;
/*     */ 
/*  49 */     this.minVal = 0.0F;
/*  50 */     this.maxVal = paramArrayOfBBIInterface.length;
/*     */ 
/*  52 */     if (this.noOfDays == 150)
/*  53 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  55 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  57 */     setBackground(Color.black);
/*  58 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  60 */     bbiFinder();
/*     */ 
/*  62 */     if (paramInt1 < paramSymQuotes.count) {
/*  63 */       this.bbiMa_parm1 = BBIMAnFinder(paramInt1);
/*     */     }
/*  65 */     if (paramInt2 < paramSymQuotes.count) {
/*  66 */       this.bbiMa_parm2 = BBIMAnFinder(paramInt2);
/*     */     }
/*  68 */     addMouseMotionListener(this);
/*     */ 
/*  70 */     if (this.bbiMa_parm1[(paramSymQuotes.count - 1)] >= this.bbiMa_parm2[(paramSymQuotes.count - 1)])
/*  71 */       this.trend = "Bullish";
/*     */     else {
/*  73 */       this.trend = "Bearish";
/*     */     }
/*  75 */     this.ep = new BBIChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  82 */     this.noOfDays = paramInt;
/*     */ 
/*  84 */     if (paramInt == 150)
/*  85 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  87 */       this.stickWidth = (1.5D * this.xScale);
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/*  94 */     this.sq = paramSymQuotes;
/*  95 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  97 */     this.bbi = new int[paramSymQuotes.count];
/*     */ 
/*  99 */     if (this.noOfDays == 150)
/* 100 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 102 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 104 */     bbiFinder();
/*     */ 
/* 106 */     if (this.parm1 < paramSymQuotes.count) {
/* 107 */       this.bbiMa_parm1 = BBIMAnFinder(this.parm1);
/*     */     }
/* 109 */     if (this.parm2 < paramSymQuotes.count) {
/* 110 */       this.bbiMa_parm2 = BBIMAnFinder(this.parm2);
/*     */     }
/* 112 */     if (this.bbiMa_parm1[(paramSymQuotes.count - 1)] >= this.bbiMa_parm2[(paramSymQuotes.count - 1)])
/* 113 */       this.trend = "Bullish";
/*     */     else {
/* 115 */       this.trend = "Bearish";
/*     */     }
/* 117 */     repaint();
/* 118 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 125 */     Arrays.fill(this.bbi, 0);
/*     */ 
/* 127 */     bbiFinder();
/*     */ 
/* 129 */     if (this.parm1 < this.sq.count) {
/* 130 */       this.bbiMa_parm1 = BBIMAnFinder(this.parm1);
/*     */     }
/* 132 */     if (this.parm2 < this.sq.count) {
/* 133 */       this.bbiMa_parm2 = BBIMAnFinder(this.parm2);
/*     */     }
/* 135 */     if (this.bbiMa_parm1[(this.sq.count - 1)] >= this.bbiMa_parm2[(this.sq.count - 1)])
/* 136 */       this.trend = "Bullish";
/*     */     else {
/* 138 */       this.trend = "Bearish";
/*     */     }
/* 140 */     repaint();
/* 141 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public int getNoOfBullish(int paramInt)
/*     */   {
/* 148 */     if (this.bbiMa_parm1[paramInt] >= this.bbiMa_parm2[paramInt]) {
/* 149 */       return this.bbi[paramInt] + 1;
/*     */     }
/* 151 */     return this.bbi[paramInt];
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 159 */     int j = 1;
/* 160 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 162 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 164 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 166 */         j = this.sq.count - 1 - i;
/* 167 */         this.m = ("( " + (String)this.sq.date.get(j) + ", BBI: " + this.df.format(this.bbi[j]) + "  BBI MA[" + this.parm1 + "]:" + this.df.format(this.bbiMa_parm1[j]) + "  BBI MA[" + this.parm2 + "]:" + this.df.format(this.bbiMa_parm2[j]) + " )");
/*     */ 
/* 170 */         this.mX = paramMouseEvent.getX();
/* 171 */         this.mY = paramMouseEvent.getY();
/* 172 */         repaint();
/* 173 */         return;
/*     */       }
/*     */ 
/* 177 */       this.m = "";
/*     */ 
/* 179 */       repaint();
/* 180 */       return;
/*     */     }
/*     */ 
/* 184 */     this.m = "";
/* 185 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 198 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 200 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 201 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 203 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt1, int paramInt2)
/*     */   {
/* 210 */     this.parm1 = paramInt1;
/* 211 */     this.parm2 = paramInt2;
/*     */ 
/* 213 */     this.bbiMa_parm1 = BBIMAnFinder(paramInt1);
/* 214 */     this.bbiMa_parm2 = BBIMAnFinder(paramInt2);
/*     */   }
/*     */ 
/*     */   public Box getBBIBox(boolean paramBoolean)
/*     */   {
/* 221 */     Box localBox = Box.createHorizontalBox();
/* 222 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("BBI");
/*     */ 
/* 224 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 225 */     this.parm2TF = new JTextField("" + this.parm2, 2);
/* 226 */     this.parm1TF.setFont(this.ssp10);
/* 227 */     this.parm2TF.setFont(this.ssp10);
/* 228 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/* 229 */     this.parm2TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 231 */     JLabel localJLabel1 = new JLabel("BBI MA[");
/* 232 */     JLabel localJLabel2 = new JLabel("] ,  BBI MA[");
/* 233 */     JLabel localJLabel3 = new JLabel("]     ");
/*     */ 
/* 235 */     localJLabel1.setFont(this.ssp10);
/* 236 */     localJLabel2.setFont(this.ssp10);
/* 237 */     localJLabel3.setFont(this.ssp10);
/*     */ 
/* 239 */     localBox.add(localJLabel1);
/* 240 */     localBox.add(this.parm1TF);
/* 241 */     localBox.add(localJLabel2);
/* 242 */     localBox.add(this.parm2TF);
/* 243 */     localBox.add(localJLabel3);
/*     */ 
/* 245 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 247 */     if (paramBoolean) {
/* 248 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 250 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 257 */     JFrame localJFrame = new JFrame();
/* 258 */     this.chgParmDialog = new JDialog(localJFrame, "Change BBI Parameters", true);
/* 259 */     Box localBox1 = Box.createVerticalBox();
/* 260 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 262 */     this.chgParmOk = new JButton("OK");
/* 263 */     this.chgParmOk.setFont(this.ssp10);
/* 264 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 265 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 267 */     this.chgParmCancel = new JButton("Cancel");
/* 268 */     this.chgParmCancel.setFont(this.ssp10);
/* 269 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 270 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 272 */     this.defaultParms = new JButton("Default");
/* 273 */     this.defaultParms.setFont(this.ssp10);
/* 274 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 275 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 276 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 278 */     localBox2.add(Box.createHorizontalGlue());
/* 279 */     localBox2.add(this.chgParmOk);
/* 280 */     localBox2.add(Box.createHorizontalStrut(5));
/* 281 */     localBox2.add(this.chgParmCancel);
/* 282 */     localBox2.add(Box.createHorizontalStrut(5));
/* 283 */     localBox2.add(this.defaultParms);
/* 284 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 286 */     localBox1.add(getBBIBox(true));
/* 287 */     localBox1.add(localBox2);
/*     */ 
/* 289 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 290 */     this.chgParmDialog.setSize(250, 100);
/* 291 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 292 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 299 */     int i = this.parm1;
/* 300 */     int j = this.parm2;
/*     */     try
/*     */     {
/* 304 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/* 305 */       j = Integer.parseInt(this.parm2TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 311 */       JOptionPane.showMessageDialog(null, "Error in BBI parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 314 */       this.parm1TF.setText("" + this.parm1);
/* 315 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 317 */       return false;
/*     */     }
/*     */ 
/* 321 */     if ((i > 200) || (j > 200))
/*     */     {
/* 323 */       JOptionPane.showMessageDialog(null, "Error in BBI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 326 */       this.parm1TF.setText("" + this.parm1);
/* 327 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 329 */       return false;
/*     */     }
/*     */ 
/* 333 */     if ((i < 2) || (j < 2))
/*     */     {
/* 335 */       JOptionPane.showMessageDialog(null, "Error in BBI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 338 */       this.parm1TF.setText("" + this.parm1);
/* 339 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 341 */       return false;
/*     */     }
/*     */ 
/* 345 */     if (i >= j)
/*     */     {
/* 347 */       JOptionPane.showMessageDialog(null, "Error in BBI parameter.BBI first parameter must be less than second parameter.", null, 0);
/*     */ 
/* 350 */       this.parm1TF.setText("" + this.parm1);
/* 351 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 353 */       return false;
/*     */     }
/*     */ 
/* 357 */     this.parm1 = i;
/* 358 */     this.parm2 = j;
/*     */ 
/* 360 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 367 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 369 */       if (!validateParm()) {
/* 370 */         return;
/*     */       }
/* 372 */       redrawChart();
/* 373 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 377 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 379 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 383 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 385 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 394 */     this.parm1TF.setText("3");
/* 395 */     this.parm2TF.setText("5");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 402 */     if (paramBoolean)
/* 403 */       this.yScale += 0.2F;
/* 404 */     else if (this.yScale >= 1.2F) {
/* 405 */       this.yScale -= 0.2F;
/*     */     }
/* 407 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 414 */     if (paramBoolean)
/* 415 */       this.xScale += 0.2F;
/* 416 */     else if (this.xScale >= 1.2F) {
/* 417 */       this.xScale -= 0.2F;
/*     */     }
/* 419 */     if (this.noOfDays == 150)
/* 420 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 422 */       this.stickWidth = (1.5D * this.xScale);
/* 423 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 430 */     this.yScale = 1.0F;
/* 431 */     this.xScale = 1.0F;
/* 432 */     if (this.noOfDays == 150)
/* 433 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 435 */       this.stickWidth = (1.5D * this.xScale);
/* 436 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 443 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 450 */     clear(paramGraphics);
/* 451 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 452 */     drawChart(localGraphics2D);
/* 453 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 483 */     this.refY = 10.0D;
/* 484 */     this.refX = 50.0D;
/* 485 */     setFont(this.ssp10);
/* 486 */     String str = "Bullish-Bearish Indicator";
/* 487 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 488 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 490 */     str = "BBI";
/* 491 */     paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 492 */     paramGraphics2D.drawString(str, 175, 10);
/*     */ 
/* 494 */     str = "BBI MA[" + this.parm1 + "]";
/* 495 */     paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 496 */     paramGraphics2D.drawString(str, 205, 10);
/*     */ 
/* 498 */     str = "BBI MA[" + this.parm2 + "]";
/* 499 */     paramGraphics2D.setPaint(new Color(255, 90, 10));
/* 500 */     paramGraphics2D.drawString(str, 265, 10);
/*     */ 
/* 503 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 504 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 505 */     paramGraphics2D.setPaint(Color.white);
/* 506 */     paramGraphics2D.draw(this.refL1);
/* 507 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 509 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 511 */       this.refX += 50.0F * this.xScale;
/* 512 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 513 */       paramGraphics2D.setPaint(Color.darkGray);
/* 514 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 518 */     for (i = 0; i < 11; i++)
/*     */     {
/* 520 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 521 */       str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 522 */       paramGraphics2D.setPaint(Color.lightGray);
/* 523 */       paramGraphics2D.drawString(str, 10, (int)this.refY);
/* 524 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 526 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 527 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 528 */       paramGraphics2D.setPaint(Color.white);
/* 529 */       paramGraphics2D.draw(this.yrefL1);
/* 530 */       paramGraphics2D.draw(this.yrefL2);
/* 531 */       paramGraphics2D.setPaint(Color.darkGray);
/* 532 */       paramGraphics2D.draw(this.gridX);
/* 533 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 537 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 538 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 539 */     this.dateRef = (this.sq.count - 1);
/* 540 */     this.daysRef = 1;
/*     */ 
/* 543 */     for (i = this.sq.count - 1; i > 0; i--)
/*     */     {
/* 545 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 547 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 550 */       if (i > this.parm1)
/*     */       {
/* 552 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.bbiMa_parm1[i] - this.minVal) * this.yfactor);
/* 553 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.bbiMa_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 555 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 556 */         paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 557 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 561 */       if (i > this.parm2)
/*     */       {
/* 563 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.bbiMa_parm2[i] - this.minVal) * this.yfactor);
/* 564 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.bbiMa_parm2[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 566 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 567 */         paramGraphics2D.setPaint(new Color(255, 90, 10));
/* 568 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 572 */       if (i > 0)
/*     */       {
/* 574 */         this.p111Y = (this.yScale * 100.0F + 10.0F - (this.bbi[i] - this.minVal) * this.yfactor);
/* 575 */         this.p222Y = (this.yScale * 100.0F + 10.0F - (this.bbi[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 577 */         this.l3.setLine(this.startPointX, this.p111Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p222Y);
/* 578 */         paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 579 */         paramGraphics2D.draw(this.l3);
/*     */       }
/*     */ 
/* 584 */       if ((i > this.parm1) && (this.bbiMa_parm1[i] - this.bbiMa_parm2[i] >= 0.0F) && (this.bbiMa_parm1[(i - 1)] - this.bbiMa_parm2[(i - 1)] < 0.0F))
/*     */       {
/* 586 */         this.x1 = this.startPointX;
/* 587 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 588 */         this.y1 = this.p1Y;
/* 589 */         this.y2 = this.p2Y;
/* 590 */         this.u1 = this.x1;
/* 591 */         this.u2 = this.x2;
/* 592 */         this.v1 = this.p11Y;
/* 593 */         this.v2 = this.p22Y;
/*     */ 
/* 595 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 596 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 598 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 599 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 601 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 602 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 604 */         paramGraphics2D.setPaint(Color.green);
/* 605 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 606 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 607 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 608 */         paramGraphics2D.draw(this.uA);
/* 609 */         paramGraphics2D.draw(this.lA);
/* 610 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 614 */       if ((i > this.parm1) && (this.bbiMa_parm1[i] - this.bbiMa_parm2[i] < 0.0F) && (this.bbiMa_parm1[(i - 1)] - this.bbiMa_parm2[(i - 1)] > 0.0F))
/*     */       {
/* 616 */         this.x1 = this.startPointX;
/* 617 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 618 */         this.y1 = this.p1Y;
/* 619 */         this.y2 = this.p2Y;
/* 620 */         this.u1 = this.x1;
/* 621 */         this.u2 = this.x2;
/* 622 */         this.v1 = this.p11Y;
/* 623 */         this.v2 = this.p22Y;
/*     */ 
/* 625 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 626 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 628 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 629 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 631 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 632 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 634 */         paramGraphics2D.setPaint(Color.red);
/* 635 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 636 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 637 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 638 */         paramGraphics2D.draw(this.uA);
/* 639 */         paramGraphics2D.draw(this.lA);
/* 640 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 644 */       if (this.dateRef == i)
/*     */       {
/* 646 */         paramGraphics2D.setFont(this.ssp9);
/* 647 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 648 */         if (this.bbiMa_parm1[i] >= this.bbiMa_parm2[i])
/* 649 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 651 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 653 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 654 */         if (this.noOfDays == 150)
/* 655 */           this.dateRef -= 10;
/*     */         else
/* 657 */           this.dateRef -= 20;
/* 658 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 662 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 663 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   private void bbiFinder()
/*     */   {
/* 672 */     for (int i = 0; i < this.sq.count; i++)
/*     */     {
/* 674 */       for (int j = 0; j < this.indicators.length; j++)
/*     */       {
/* 676 */         this.bbi[i] += this.indicators[j].getBBIdata(i);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private float[] BBIMAnFinder(int paramInt)
/*     */   {
/* 687 */     float[] arrayOfFloat = new float[this.sq.count];
/*     */ 
/* 689 */     for (int i = paramInt; i < this.sq.count; i++)
/*     */     {
/* 691 */       float f = 0.0F;
/* 692 */       for (int j = i; j >= i - (paramInt - 1); j--)
/*     */       {
/* 694 */         f += this.bbi[j];
/*     */       }
/*     */ 
/* 697 */       arrayOfFloat[i] = (f / paramInt);
/*     */     }
/*     */ 
/* 701 */     return arrayOfFloat;
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 767 */     FileDownloader localFileDownloader = new FileDownloader();
/* 768 */     localFileDownloader.downloadFiles();
/* 769 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 773 */     JFrame localJFrame = new JFrame("Test");
/* 774 */     localJFrame.setDefaultCloseOperation(3);
/*     */ 
/* 776 */     localJFrame.pack();
/* 777 */     localJFrame.setSize(850, 175);
/* 778 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel bbiL;
/*     */     private JLabel bbiMaL1;
/*     */     private JLabel bbiMaL2;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 711 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 712 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 716 */       this.title = new JLabel("BBI");
/* 717 */       this.bbiL = new JLabel("BBI: " + BBIChart.this.df.format(BBIChart.this.bbi[(BBIChart.this.sq.count - 1)]));
/* 718 */       this.bbiMaL1 = new JLabel("BBI MA[" + BBIChart.this.parm1 + "]: " + BBIChart.this.df.format(BBIChart.this.bbiMa_parm1[(BBIChart.this.sq.count - 1)]));
/* 719 */       this.bbiMaL2 = new JLabel("BBI MA[" + BBIChart.this.parm2 + "]: " + BBIChart.this.df.format(BBIChart.this.bbiMa_parm2[(BBIChart.this.sq.count - 1)]));
/*     */ 
/* 721 */       this.trendL = new JLabel("Trend: " + BBIChart.this.trend);
/* 722 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/bbi.htm", "Help on BBI");
/*     */ 
/* 724 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 726 */       this.bbiL.setFont(this.valuesF);
/* 727 */       this.bbiMaL1.setFont(this.valuesF);
/* 728 */       this.trendL.setFont(this.valuesF);
/* 729 */       this.bbiMaL2.setFont(this.valuesF);
/*     */ 
/* 731 */       this.buttonsPanel.add(this.chb);
/* 732 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 733 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 735 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 737 */       add(this.title);
/* 738 */       add(this.bbiL);
/* 739 */       add(this.bbiMaL1);
/* 740 */       add(this.bbiMaL2);
/* 741 */       add(new JLabel(" "));
/* 742 */       add(this.trendL);
/* 743 */       add(this.buttonsPanel);
/* 744 */       add(Box.createVerticalGlue());
/*     */ 
/* 746 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 753 */       this.bbiL.setText("BBI: " + BBIChart.this.df.format(BBIChart.this.bbi[(BBIChart.this.sq.count - 1)]));
/* 754 */       this.bbiMaL1.setText("BBI MA[" + BBIChart.this.parm1 + "]: " + BBIChart.this.df.format(BBIChart.this.bbiMa_parm1[(BBIChart.this.sq.count - 1)]));
/* 755 */       this.bbiMaL2.setText("BBI MA[" + BBIChart.this.parm2 + "]: " + BBIChart.this.df.format(BBIChart.this.bbiMa_parm2[(BBIChart.this.sq.count - 1)]));
/* 756 */       this.trendL.setText("Trend: " + BBIChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     BBIChart
 * JD-Core Version:    0.6.0
 */